$(function(){
	initPage();
});

function initPage(){
	$('#exportAdviserSel').combobox({
		multiple:false,
		editable:false,
		url:rootPath+'/op/list',
	    valueField:'scOpId',
	    textField:'opName',
	    formatter:function(row){
	    	return "["+row.opCode+"] "+row.lastName+"."+row.firstName+"/"+row.opName;
	    }
	});
}

//导出事件报表
function exportReport(){
	//获取导出条件
	var expParam = {};
	//责任顾问Id
	expParam.expConsultantId = $('#exportAdviserSel').combotree('getValue');
	if(!expParam.expConsultantId){
		$.messager.alert(i18n.dialog.AlertTitle,i18n.stat.ConsultantEmpty);
		return;
	}
	//日期范围
	var dateRange = $("#weekSelect").val();
	if(!dateRange){
		$.messager.alert(i18n.dialog.AlertTitle,i18n.stat.ExportDateEmpty);
		return;
	}
	var dateInfo = dateRange.split("--");
	expParam.expStartDate = dateInfo[0];
	expParam.expEndDate = dateInfo[1];
	//构建导出URL地址
	var expURL = rootPath + "/stat/report/exportTicketSumReport?a=1";
	for(var p in expParam){
		expURL += "&"+p+"="+expParam[p];
	}
	$("#exportIframe").attr("src",expURL);
}

//导出重置
function exportReset(){
	//责任顾问Id
	$('#exportAdviserSel').combobox('setValue','');
}
